import { ReqPage, ResPage } from '@/api/interface'
import { TBY } from '@/api/config/servicePort'
import http from '@/api'

export namespace WildCamera {
  /**查询参数 */
  export interface Query extends ReqPage {
    name?: string
    code?: string
    deptId?: string
  }

  /**列表内容 */
  export interface Record {
    id: number
    name: string
    code: string
    longitude: string
    latitude: string
    deptId: string
    category: string
    brand: string
    ip: string
    registerInfo: string
    shotDate: string
    pitpatDate: string
    powerLevel: number
    online: number
  }

  /**详情 */
  export interface Form {
    id: number
    name: string
    code: string
    longitude: string
    latitude: string
    deptId: string
    category: string
    brand: string
    ip: string
    registerInfo: string
    shotDate: string
    pitpatDate: string
    powerLevel: number
    online: number
  }
}

// 分页查询
export const pageWildCamera = (params: WildCamera.Query) => {
  return http.get<ResPage<WildCamera.Record>>(TBY + `/wild_camera/page`, params)
}

// 列表查询
export const listWildCamera = (params: WildCamera.Query) => {
  return http.get<WildCamera.Record[]>(TBY + `/wild_camera/list`, params)
}

// 详情信息
export const getWildCameraDetail = (id: number) => {
  return http.get<Partial<WildCamera.Form>>(TBY + `/wild_camera/get`, { id }, { loading: false })
}

// 新增或修改
export const saveOrUpdateWildCamera = (params: Partial<WildCamera.Form>) => {
  return http.post(TBY + `/wild_camera/save`, params)
}

// 删除
export const removeWildCamera = (id: number) => {
  return http.delete(TBY + `/wild_camera/delete`, { id })
}

// 验证设备编码是否存在
export const codeExist = (code: string, id?: number) => {
  return http.get<boolean>(TBY + '/wild_camera/exist', { code, id }, { loading: false })
}
